#include <iostream>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

int main()
{
   int theInt;
   do
   {
      string line;
      cout << "Enter an int ... ";
      getline(cin, line);
      istringstream is(line);
      is >> theInt;
      if (!is)
         is.clear();
      assert(is);
   } while (theInt < 1 || theInt > 5);
   cout << "You entered " << theInt;
}
